window.pageTools = window.pageTools || {};
(function(){
    function Login(isLogin, selector, eventListener){
        this.isLogin = isLogin;
        this.selector = $(selector);
        this.init();
        this.eventListener = eventListener;
    }
    Login.prototype.init = function(){
        var isShow = this.isLogin ? 'nono':'block';
        var buttonText = this.isLogin?'login':'register';

        this.dialog = $('\
        <div class="dialog">\
            <button class="close_btn">&times;</button>\
            <div class="input-box">\
                <input type="text" placeholder="username">\
                <input type="password" placeholder="password">\
                <input type="password" placeholder="enter password" class="again-pwd">\
                <button class="btn"></button>\
            </div>\
        </div>');

        this.superView = $('body');

        this.superView.append(this.dialog);
        $('.again-pwd').css('display', isShow);
        $(".btn").text(buttonText).click(function(){
            this.dialog.remove();
            this.dialog = null;
            this.eventListener();
        }.bind(this));
    
        $(".close_btn").click(function(){
            this.dialog.remove();
            this.dialog = null;
            this.eventListener();
        }.bind(this));
    
    }
    pageTools.Login = Login;



})();